import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class UserFrame extends JFrame {
    private JTable carTable;
    private JButton rentCarButton;
    private JButton returnCarButton;
    private JButton simulatePaymentButton;

    public UserFrame() {
        setTitle("用户界面");
        setSize(600, 400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());

        carTable = new JTable();
        JScrollPane scrollPane = new JScrollPane(carTable);
        panel.add(scrollPane, BorderLayout.CENTER);

        JPanel buttonPanel = new JPanel();
        rentCarButton = new JButton("租车");
        returnCarButton = new JButton("换车");
        simulatePaymentButton = new JButton("模拟付款");

        buttonPanel.add(rentCarButton);
        buttonPanel.add(returnCarButton);
        buttonPanel.add(simulatePaymentButton);

        panel.add(buttonPanel, BorderLayout.SOUTH);

        rentCarButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // 租车逻辑
            }
        });

        returnCarButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // 换车逻辑
            }
        });

        simulatePaymentButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // 模拟付款逻辑
            }
        });

        add(panel);
    }
}
